import org.jbox2d.dynamics.Body;
import pulpcore.animation.BindFunction;
import pulpcore.sprite.Sprite;
import pulpfizz.pulp.body.Java2DBodySprite;
import pulpfizz.pulp.body.PhysicsLayer;

import java.awt.*;

/**
 * Created by will
 * Date: May 21, 2008 5:27:36 PM
 */
public class Target extends Java2DBodySprite {
    Sprite shadow;

    public Target(Body body, PhysicsLayer physics, float sharpness) {
        super(body, physics, sharpness, Color.white,Color.red,Color.BLACK);

        Color greyshadow = new Color(50, 50, 50, 100);
        shadow = new Java2DBodySprite(body,physics,sharpness, greyshadow,greyshadow,greyshadow);
//        shadow = new FilledSprite(this.x.get(),this.y.get(),this.width.get(),this.height.get(), Colors.rgba(Colors.BLACK,100));
        shadow.x.bindTo(posX());
        shadow.y.bindTo(posY());
        shadow.bindSizeTo(this);
        shadow.angle.bindTo(this.angle);
        shadow.alpha.bindTo(this.alpha);
    }

    public Target(Body body, PhysicsLayer physics) {
        this(body, physics,1);
    }

    BindFunction posX() {
        return new BindFunction() {
            public Number f() {
                return (posX(body).f().doubleValue() +3);
            }
        };
    }
    BindFunction posY() {
        return new BindFunction() {
            public Number f() {
                return (posY(body).f().doubleValue() +1);
            }
        };
    }

    public Sprite getShadow() {
        return shadow;
    }
}
